<template>
    <div>
      <Content style="width:90%">
        <Form :label-width="140">
          <FormItem label="频道名称" required>
            <Input v-model="dataBus.channelName" placeholder="请输入频道名称"></Input>
          </FormItem>
          <FormItem label="频道编码" required>
            <Input v-model="dataBus.channelCode" placeholder="请输入频道编码"></Input>
          </FormItem>
					<FormItem label="频道类型" required>
						<Select class="view-input" placeholder="请选择频道类型" v-model="dataBus.channelType">
							<Option v-for="(item,index) in seletions" :value="item.id" :key="index">{{item.name}}</Option>
						</Select>
					</FormItem>
          <FormItem label="排序" required>
            <InputNumber :min="1" v-model="dataBus.sortIndex" placeholder="请输入排序"></InputNumber>
          </FormItem>
          <FormItem label="外链地址">
            <Input v-model="dataBus.extLinks" placeholder="请输入外链地址"></Input>
          </FormItem>
          <FormItem label="是否启用">
            <RadioGroup v-model.number="dataBus.channelStatus">
              <Radio :label="1">
                <span>开启</span>
              </Radio>
              <Radio :label="0">
                <span>关闭</span>
              </Radio>
            </RadioGroup>
          </FormItem>
          <FormItem>
            <Button type="primary" @click="Submit">提交</Button>
          </FormItem>
        </Form>
      </Content>
    </div>
</template>
<script>
export default {
  name: "GroupCreate",
  props: {
		dataBus: Object,
    callbank: Function
  },
  data() {
    return {
			seletions: this.$dict.channelType.data
    }
  },
  created() {
    
  },
  methods: {
    Submit() {
			let dataForm = {
				channelId: this.dataBus.channelId,
				channelName: this.dataBus.channelName,
				channelCode: this.dataBus.channelCode,
				channelType: this.dataBus.channelType,
				extLinks: this.dataBus.extLinks,
				sortIndex: this.dataBus.sortIndex,
				channelStatus: this.dataBus.channelStatus
			}
      new this.$rest({
        gateway: 'agrobiz',
        service: "agrobiz-msg",
        url: "/v1.0/news/channel",
        data: {
          pojo: dataForm
        },
        action: (res) => {
          if (res.data.code === 20000) {
            this.$Message.success({
              content: '修改成功',
            })
            this.callbank()
          } else {
            this.$Message.error({
              content: res.data.msg
            })
          }
        },
      }).put()
    }
  }
}
</script>